package server.util;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.IOException;
import java.util.Base64;

public class Base64Util {

    /***
     * BASE64解密
     * @param key
     * @return
     * @throws Exception
     */
    public static String decryBASE64(String key) throws Exception {
        byte[] decodedBytes = (new BASE64Decoder()).decodeBuffer(key);
        return new String(decodedBytes);
    }

    /***
     * BASE64加密
     * @param key
     * @return
     * @throws Exception
     */
    public static String encryptBASE64(String key) throws Exception{
        return Base64.getEncoder().encodeToString(key.getBytes());
    }

}
